var vm = new Vue({
	el: '#app',
	data: {
		items: [],
		loaded: false
	},
	mounted: function() {
		getMailList();
	}
});

$(document).on("click", ".delete", function() {
	$.confirm("您确定要删除吗?", "删除操作", function() {
		var updateMailListReqbody = {
			"aId": aid
		};
		$.ajax({
			type: "POST",
			url: ip + "platform/user/deleteAddressBook.m",
			xhrFields: {
				withCredentials: true
			},
			crossDomain: true,
			data: updateMailListReqbody,
			success: function(data) {
				if(data.statusCode == 0) {
					$.toptip("删除联系人成功！", 'success');
					setTimeout(function(){
				        mui.openWindow({
							createNew: true, // 打开并且刷新：true刷新，false不刷新
							show: {
								autoShow: true,
								aniShow: 'fade-in'
							},
							url: 'mailList.html',
							id: 'mailList'
						});
				    },500);
				} else if(data.statusCode == 1000) {
					loginError();
				} else {
					$.toptip(data.resultDesc, 'error');
				}
			}
		});
	}, function() {
		//取消操作
	});
});

$(function() {
	FastClick.attach(document.body);
});
var aid;

function getMailList() {
	var txl = localStorage.getItem("txl");
	var obj = JSON.parse(txl);
	aid = obj.aId;
	$("#name").text(obj.friend_name);
	$("#friend_addr").text(obj.friend_addr);
	$("#title").text(obj.title);
	$("#names").text(obj.name);
	localStorage.setItem('qb', obj.friend_addr);
}